package com.android.equipment.adapter

import android.annotation.SuppressLint
import android.graphics.Color
import android.widget.TextView
import com.android.equipment.R
import com.android.equipment.dao.Device
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class RelevanceDeviceAdapter(layoutRes: Int): BaseQuickAdapter<Device,BaseViewHolder>(layoutRes) {
    @SuppressLint("SetTextI18n")
    override fun convert(holder: BaseViewHolder, item: Device) {
        val tvName = holder.getView<TextView>(R.id.tv_device_name)
        //空闲状态 说明暂时每人绑定

        if (item.isOccupy){ //占用状态
            tvName.isEnabled = false
        }else {
            tvName.isEnabled = true
            if (item.isSelect){
                tvName.setBackgroundResource(R.drawable.shape_radius_12_solid_white_stroke_42e7af)
                tvName.setTextColor(Color.parseColor("#42E7AF"))
            }else{
                tvName.setBackgroundResource(R.drawable.shape_radius_12_solid_white_stroke_e6e9ef)
                tvName.setTextColor(Color.parseColor("#1D2129"))
            }
        }

        tvName.text = "${item.deviceName}${item.deviceCode}"
    }
}